import React from 'react'
import CmtItem from '@/components/CmtItem'

//定义父组件
export default class CmtList extends React.Component{
    constructor(){
        super()
        this.state={
            CommentList:[
                {id:1, user:'张三',cotent:'hello,java'},
                {id:2, user:'李四',cotent:'hello,js'},
                {id:3, user:'王五',cotent:'hello,react'},
                {id:4, user:'赵六',cotent:'hello,vue'},
                {id:5, user:'孙七',cotent:'hello,c'},
                {id:6, user:'刘八',cotent:'hello,c++'}
            ]
        }
    }
    render(){
        return <div>
            {/* 在jsx中如果想在行内写样式，不能写string格式 */}
            <h1 style={{color:'red',fontSize:'35px', fontWeight:200, textAlign:'center'}}>这是评论列表组件</h1>
            {this.state.CommentList.map(item=><CmtItem {...item} key={item.id}></CmtItem>)}
        </div>
    }
}